Should you develop a cavity as a result of tooth decay, then your dentist will remove the decayed area of tooth (usually with a drill using {local anesthetic}) & restore the tooth to its original size & shape with filling material.
Depending on depth of decay, your dentist will place a lining (insulating layer) to protect sensitive nerve & pulp tissue inside the cavity. For well over 100yrs, dentists have filled cavities with silver amalgam. It is still very widely used for restorations in back teeth. However, tooth colored materials have improved remarkably in recent years.
Great advances in filling techniques have been made since the advent of adhesive materials. These materials can actually bond to {enamel} & {dentine}, this enables fillings to be placed with the minimum removal of sound tooth material.